home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 2.0 KB | 87 lines | [TEXT/MPS ] |
- /*
- # File: TempRef.th
- #
- # Contains: Internal header for use by TempObj.h
- #
- # Owned by: Jens Alfke
- #
- # Copyright: © 1995 - 1996 by Apple Computer, Inc., all rights reserved.
- #
- # Change History (most recent first):
- #
- # <2> 5/24/96 jpa 1322106: Add operator "&" so taking address
- # works as expected. 1246074:
- # Native-exception optimizations.
- #
- # In Progress:
-
- */
-
- // This header is a utility used by TempObj.h. Do not include it directly unless you
- // really know what you're doing -- see the Tech Note "Temporary Objects/References".
-
- #ifndef SOM_ODDocument_xh
- #include <Document.xh>
- #endif
-
- #ifndef _T_
- #error _T_ must be defined before including a .th file
- #endif
- #ifndef _C_
- #error _C_ must be defined before including a .th file
- #endif
-
- //===========================================================================
- // TempObj <T>
- //===========================================================================
-
- #ifdef _TMPL_IMPL_
-
- // Implementation of the TempRef constructor/destructor.
- // Used only if we don't use native exceptions.
- _C_::_C_( _T_ *obj )
- {
- fObj = obj;
- }
-
- _C_::~_C_( )
- {
- // Prevent compiler from inlining synthesized destructor
- // which causes code bloat.
- }
-
- #else
-
- #if defined(__SC__) || defined(__MRC__)
- // Some of the typecasts below offend certain compilers.
- #pragma options(!warn_cast_incomplete_type)
- #endif
-
- // Declaration of the TempRef class
- class _C_ :public BaseTempRef
- {
- public:
- #ifdef _NATIVE_EXCEPTIONS_
- _C_( _T_* t ) {fObj = (ODRefCntObject*)t;}
- ~_C_( ) { }
- #else
- _C_( _T_* );
- ~_C_( );
- #endif
- _T_* operator-> () {return (_T_*)fObj;}
- _T_** operator& () {return (_T_**)&fObj;}
- operator _T_* () {return (_T_*)fObj;}
- _T_* operator=( _T_ *t ) {fObj=(ODRefCntObject*)t; return t;}
-
- _T_* DontRelease() {_T_* temp=(_T_*)fObj; fObj=kODNULL; return temp;}
- };
-
- #if defined(__SC__) || defined(__MRC__)
- #pragma options(warn_cast_incomplete_type) // undo previous pragma
- #endif
- #endif
-
- #undef _T_
- #undef _C_
-
-